import http from '../index'

// 分页获取字典
export const getDicts = ({ ascended = null, current = null, size = null, sortFieldName = null, dictKey = null, dictName = null, }) => {
    return http.get("dicts", { ascended, current, size, sortFieldName, dictKey, dictName })
}

// 根据sid获取字典
export const getDictDetail = ({ sid }) => {
    return http.get("dicts/" + sid)
}

// 根据字典key获取成员信息
export const getDictMembersByKey = ({ key }) => {
    return http.get("dicts/by-key/" + key)
}

// 新增字典
export const addDict = ({ dictKey, dictName, deletable = null, note = null, status = null }) => {
    return http.post("dicts", { dictKey, dictName, deletable, note, status })
}

// 修改字典
export const editDict = ({ sid, dictKey, dictName, deletable = null, note = null, status = null }) => {
    return http.put("dicts/" + sid, { dictKey, dictName, deletable, note, status })
}

// 批量删除字典
export const delDicts = ({ sidList }) => {
    return http.put("dicts/delete", { sidList })
}

// 分页获取字典成员
export const getDictMembers = ({ ascended = null, current = null, size = null, sortFieldName = null, dictKey = null, memberKey = null, memberName = null }) => {
    return http.get("dict-members", { ascended, current, size, sortFieldName, dictKey, memberKey, memberName })
}

// 根据sid获取字典成员
export const getDictMemberDetail = ({ sid }) => {
    return http.get("dict-members/" + sid)
}

// 新增字典成员
export const addDictMember = ({ dictKey, memberKey, memberName, deletable = null, note = null, status = null, viewSort = null }) => {
    return http.post("dict-members", { dictKey, memberKey, memberName, deletable, note, status, viewSort })
}

// 修改字典成员
export const editDictMember = ({ sid, dictKey, memberKey, memberName, deletable = null, note = null, status = null, viewSort = null }) => {
    return http.put("dict-members/" + sid, { dictKey, memberKey, memberName, deletable, note, status, viewSort })
}

// 批量删除字典成员
export const delDictMembers = ({ sidList }) => {
    return http.put("dict-members/delete", { sidList })
}
